package com.test.dababy.dababy_00_analytics.dababydata_sdk.dababytask;

import android.content.Context;
import android.text.TextUtils;

import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababybeans.DababyASRequestPms;
import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababyhttp.DababyASReqstManger;
import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababylogger.DababyASLger;
import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababyservices.DababyASStoeIfo;
import com.test.dababy.dababy_00_path.Paths_dababy;
import com.test.dababy.dababy_00_utils.DababyUtil;

import java.util.function.Supplier;


public class DababyASDevcStorTsk implements Supplier<String> {

    private final static String TAG = "ASDeviceStoreTask";

    private final String mTaskId;
    private final Context mContext;

    public String hZ2J="";
    public char aA9F='s';
    public double fri6=0.1719212422724773;
    public String p323="";

    public void eHAV3(){
        new Thread(() -> {
            try {
                sethZ2J(String.valueOf(aA9F)+fri6+p323);
                if (hZ2J==null) sethZ2J("");
            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    }

    public void sethZ2J(String hZ2J) {
        this.hZ2J = hZ2J;
    }

    public void setaA9F(char aA9F) {
        this.aA9F = aA9F;
    }

    public void setFri6(double fri6) {
        this.fri6 = fri6;
    }

    public void setP323(String p323) {
        this.p323 = p323;
    }

    public DababyASDevcStorTsk(Context context, String taskId) {
        this.mContext = context;
        this.mTaskId = taskId;
    }

    @Override
    public String get()  {
        // 日志标记
        DababyASLger.d_dababy(TAG, TAG + " 执行中...");

        // 过滤条件
        if (TextUtils.isEmpty(Paths_dababy.PATH_STORAGE)) {
            return mTaskId + "";
        }

        String infoBeans = DababyASStoeIfo.getZipString_dababy(mContext);
        if (TextUtils.isEmpty(infoBeans)) {
            // 日志标记
            DababyASLger.d_dababy(TAG, "获取存储信息出错：数据为空");
            return mTaskId + "";
        }

        DababyASRequestPms netParams = new DababyASRequestPms();
        eHAV3();
        netParams.setDSG_dababy(infoBeans);
//        String result = new Gson().toJson(netParams).trim();
        String result = netParams.toEncryptParams_dababy(Paths_dababy.PATH_STORAGE);

        // 上报请求
        String url = DababyUtil.getCommonPath_dababy();
        new DababyASReqstManger.Builder_dababy().setReqId_dababy(this.mTaskId).setUrl_dababy(url).setBody_dababy(result).build_dababy().doPostRqst_dababy();

        return mTaskId + "";
    }

    public String getmTaskId() {
        return mTaskId;
    }

    public Context getmContext() {
        return mContext;
    }


}
